package no.hio.wsclient.vo;

import no.hio.wsproviderproduct.Product;
import no.hio.wsproviderstock.StockItem;


/**
 * Representation of a product + stockinformatin
 * @author andreas
 * @version 1.0
 */
public class ProductStock {
	
	StockItem s;
	Product p;
	
	
	public ProductStock()
	{
		s = new StockItem();
		p = new Product();
		setProductID(-1);
	}
	
	public StockItem getStockItem()
	{
		return s;
	}
	
	public void setStockItem(StockItem s) throws UnsupportedOperationException
	{
		if(getProductID() != -1 && s.getProductID() != p.getProductID()) 
			throw new UnsupportedOperationException("ProductID must be the same on StockItem and Product");
		this.s = s;
	}
	
	public Product getProduct()
	{
		return p;
	}
	
	public void setProduct(Product p) throws UnsupportedOperationException
	{
		if(getProductID() != -1 && s.getProductID() != p.getProductID())
			throw new UnsupportedOperationException("ProductID must be the same on StockItem and Product");
		
		this.p = p;
	}
	
	/**
	 * @return the productID
	 */
	public int getProductID() {
		return p.getProductID();
	}
	/**
	 * @param productID the productID to set
	 */
	public void setProductID(int productID) {
		p.setProductID(productID);
	}
	/**
	 * @return the numInStock
	 */
	public int getNumInStock() {
		return s.getNumInStock();
	}
	/**
	 * @param numInStock the numInStock to set
	 */
	public void setNumInStock(int numInStock) {
		s.setNumInStock(numInStock);
	}
	/**
	 * @return the price
	 */
	public double getPrice() {
		return p.getPrice();
	}
	/**
	 * @param price the price to set
	 */
	public void setPrice(double price) {
		p.setPrice(price);
	}
	/**
	 * @return the title
	 */
	public String getTitle() {
		return p.getTitle();
	}
	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		p.setTitle(title);
	}
	/**
	 * @return the description
	 */
	public String getDescription() {
		return p.getDescription();
	}
	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		p.setDescription(description);
	}
	/**
	 * @return the stockLocation
	 */
	public String getStockLocation() {
		return s.getStockLocation();
	}
	/**
	 * @param stockLocation the stockLocation to set
	 */
	public void setStockLocation(String stockLocation) {
		s.setStockLocation(stockLocation);
	}
	
	public String toString()
	{
		StringBuffer buff = new StringBuffer();
		
		buff.append("ProductID: ")
		.append(getProductID())
		.append(" Title:")
		.append(getTitle())
		.append(" Description:")
		.append(getDescription())
		.append(" Price:")
		.append(getPrice())
		.append(" NumInStock:")
		.append(getNumInStock())
		.append(" StockLocation:")
		.append(getStockLocation());
		
		
		
		return buff.toString();
	}
}
